Page({
  data: {
    bgd85: "",
    bgd86: "",
    bgd87: "",
    bgd88: "",
    bgd89: "",
    bgd90: "",
    bgd91: "",
    bgd92: "",
    bgd93: "",
    bgd94: "",
    bgd95: "",
    bgd96: "",
    bgd97: "",
    bgd98: "",
    bgd99: "",
    bgd100: "",
    bgd101: "",
    bgd102: "",
    bgd103: "",
    bgd104: "",
    bgd105: "",
    bgd106: "",
    bgd107: "",
    bgd108: "",
    bgd109: "",
    bgd110: "",
    bgd111: "",
    bgd112: "",
  },
  onLoad: function () {
    console.log("order进来");
    //wx.clearStorage();
    var that = this;
    wx.request({
      url: 'https://www.szz5.com/admin/selectAll',
      method: 'POST',
      data: {},
      success: function (res) {
        console.info("++++++++++=1", JSON.stringify(res));
        var list = res.data;
        console.info("++++++++++=2", JSON.stringify(list));
        if (list != null) {
          for (var index in list) {
            console.info("++++++++++=3", list[index]);
            var bathid = list[index];
            if (bathid == '085') {
              console.info("进来001");
              that.setData({
                bgd85: "red"
              });
            }
            if (bathid == "086") {
              console.info("进来002");
              that.setData({
                bgd86: "red"
              });
            }
            if (bathid == "087") {
              that.setData({
                bgd87: "red"
              });
            }
            if (bathid == "088") {
              that.setData({
                bgd88: "red"
              });
            }
            if (bathid == "089") {
              that.setData({
                bgd89: "red"
              });
            }
            if (bathid == "090") {
              that.setData({
                bgd90: "red"
              });
            }
            if (bathid == "091") {
              that.setData({
                bgd91: "red"
              });
            }
            if (bathid == "092") {
              that.setData({
                bgd92: "red"
              });
            }
            if (bathid == "093") {
              that.setData({
                bgd93: "red"
              });
            }
            if (bathid == "094") {
              that.setData({
                bgd94: "red"
              });
            }
            if (bathid == "095") {
              that.setData({
                bgd95: "red"
              });
            }
            if (bathid == "096") {
              that.setData({
                bgd96: "red"
              });
            }
            if (bathid == "097") {
              that.setData({
                bgd97: "red"
              });
            }
            if (bathid == "098") {
              that.setData({
                bgd98: "red"
              });
            }
            if (bathid == "099") {
              that.setData({
                bgd99: "red"
              });
            }
            if (bathid == "100") {
              that.setData({
                bgd100: "red"
              });
            }
            if (bathid == "101") {
              that.setData({
                bgd101: "red"
              });
            }
            if (bathid == "102") {
              that.setData({
                bg102: "red"
              });
            }
            if (bathid == "103") {
              that.setData({
                bgd103: "red"
              });
            }
            if (bathid == "104") {
              that.setData({
                bgd104: "red"
              });
            }
            if (bathid == "105") {
              that.setData({
                bgd105: "red"
              });
            }
            if (bathid == "106") {
              that.setData({
                bgd106: "red"
              });
            }
            if (bathid == "107") {
              that.setData({
                bgd107: "red"
              });
            }
            if (bathid == "108") {
              that.setData({
                bgd108: "red"
              });
            }
            if (bathid == "109") {
              that.setData({
                bgd109: "red"
              });
            }
            if (bathid == "110") {
              that.setData({
                bgd110: "red"
              });
            }
            if (bathid == "111") {
              that.setData({
                bgd111: "red"
              });
            }
            if (bathid == "112") {
              that.setData({
                bgd112: "red"
              });
            }
          }

          // wx.showToast({
          //   title: '获取数据失败',      
          //   duration: 1500      
          // })
        }
      }
    })
  },
  gotoresult: function (e) {
    var ID = e.currentTarget.id;
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
    var stor = wx.getStorageSync("userInfo");
    var getkey = wx.getStorageSync("key1");
    if (stor == null || stor == "") {
      console.log("stor" + stor);
      wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');

            wx.hideToast()
            wx.switchTab({
              url: '../../login/login'
            })

            console.log('1');
            // return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })
    } else if (getkey) {
      wx.showModal({
        title: '提示',
        content: '您已经选择过！',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    } else {

      wx.request({
        url: 'https://www.szz5.com/admin/byBathId',
        method: 'POST',
        data: { bathId: ID },
        success: function (res) {
          console.info("++++++++++=4", JSON.stringify(res));
          if (res.data == '1') {
            wx.showModal({
              title: '提示',
              content: '此澡位已被预订！',
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  return;
                } else if (res.cancel) {
                  console.log('用户点击取消');
                  return;
                }
              }
            })
          }
        }

      })
      wx.showModal({
        title: '提示',
        content: '是否预定该位置',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.setStorageSync("keykey", ID);
            wx.navigateTo({
              url: '../../seltime/seltime',
            })
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);

    //       return;
    //     }
    //   },
    // });



  }



})